var url = location.href;
//url = encodeURIComponent(url);
//var name = $("#nickName").text();
//获取分享页面的title作为分享朋友圈的内容
var tit ;
var wxobj = new Object();
wxobj.url= url;
var wxdata = JSON.stringify(wxobj);
$.ajax({  
    type : "POST",  
    url : common_url+"800826",  
    dataType : "json",  
    data:wxdata,  
    success : function(data) {  
    	console.log(data);
        wx.config({  
            debug: false,  
            appId: data.appid,  
            timestamp: data.timestamp,  
            nonceStr: data.nonceStr,  
            signature: data.signature,          
            jsApiList: [  
                'checkJsApi',  
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'onMenuShareQQ' 
            ]  
        }); 
        wx.error(function (res) {
            if(res.errMsg!='config.ok'){
                alert("微信接口错误："+res.errMsg);
            }
        });
    },  
    error: function(xhr, status, error) {  
        alert("configerror:"+status);  
        alert(xhr.responseText);  
    }
});  
   wx.ready(function () {  
   	wx.onMenuShareTimeline({
	title: tit,
	      link: url,
	      imgUrl: 'http://www.mzdykt.com/classroom/images/minlogo.png',
	      trigger: function (res) {
	        //alert('用户点击分享到朋友圈');
	      },
	      success: function (res) {
	        alert('已分享');
	      },
	      cancel: function (res) {
	        alert('已取消');
	      },
	      fail: function (res) {
	        alert(JSON.stringify(res));
	      }
	}); 
    wx.onMenuShareQQ({
	    title: tit, // 分享标题
	    desc: '精彩尽在第一课堂，赶快点开吧', // 分享描述
	    link: url, // 分享链接
	    imgUrl: 'http://www.mzdykt.com/classroom/images/minlogo.png', // 分享图标
	    success: function () { 
	    	alert('已分享');
	    },
	    cancel: function () { 
	    	alert('已取消');
	    }
	});
   	wx.onMenuShareAppMessage({

    title: tit, // 分享标题

    desc: "精彩尽在第一课堂，赶快点开吧", // 分享描述

    link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
 	imgUrl: 'http://www.mzdykt.com/classroom/images/minlogo.png',
      trigger: function (res) {
      //  alert('用户点击发送给朋友');
      },
      success: function (res) {
        alert('已分享');
      },
      cancel: function (res) {
        alert('已取消');
      },
      fail: function (res) {
        alert(JSON.stringify(res));
      }
    });

}); 